$OpenBSD: patch-media_audio_openbsd_audio_manager_openbsd_cc,v 1.23 2014/11/19 21:27:32 robert Exp $
--- media/audio/openbsd/audio_manager_openbsd.cc.orig.port	Wed Nov 19 05:53:04 2014
+++ media/audio/openbsd/audio_manager_openbsd.cc	Wed Nov 19 08:38:26 2014
@@ -4,55 +4,25 @@
 
 #include "media/audio/openbsd/audio_manager_openbsd.h"
 
-#include <fcntl.h>
-
-#include "base/command_line.h"
-#include "base/file_path.h"
-#include "base/stl_util.h"
 #include "media/audio/audio_output_dispatcher.h"
-#include "media/audio/audio_parameters.h"
-#include "media/audio/pulse/pulse_output.h"
-#include "media/audio/pulse/pulse_stubs.h"
-#include "media/base/channel_layout.h"
+#include "media/audio/sndio/sndio_output.h"
 #include "media/base/limits.h"
 #include "media/base/media_switches.h"
 
-using media_audio_pulse::kModulePulse;
-using media_audio_pulse::InitializeStubs;
-using media_audio_pulse::StubPathMap;
-
 namespace media {
 
 // Maximum number of output streams that can be open simultaneously.
-static const int kMaxOutputStreams = 50;
+static const int kMaxOutputStreams = 4;
 
 // Default sample rate for input and output streams.
 static const int kDefaultSampleRate = 48000;
 
-static const base::FilePath::CharType kPulseLib[] =
-    FILE_PATH_LITERAL("libpulse.so.0");
-
-// Implementation of AudioManager.
-static bool HasAudioHardware() {
-  int fd;
-  const char *file;
-
-  if ((file = getenv("AUDIOCTLDEVICE")) == 0 || *file == '\0')
-    file = "/dev/audioctl";
-
-  if ((fd = open(file, O_RDONLY)) < 0)
-    return false;
-
-  close(fd);
+bool AudioManagerOpenBSD::HasAudioOutputDevices() {
   return true;
 }
 
-bool AudioManagerOpenBSD::HasAudioOutputDevices() {
-  return HasAudioHardware();
-}
-
 bool AudioManagerOpenBSD::HasAudioInputDevices() {
-  return HasAudioHardware();
+  return false;
 }
 
 AudioParameters AudioManagerOpenBSD::GetInputStreamParameters(
@@ -69,19 +39,9 @@ AudioParameters AudioManagerOpenBSD::GetInputStreamPar
 }
 
 AudioManagerOpenBSD::AudioManagerOpenBSD(AudioLogFactory* audio_log_factory)
-    : AudioManagerBase(audio_log_factory),
-      pulse_library_is_initialized_(false) {
+    : AudioManagerBase(audio_log_factory) {
+  DLOG(WARNING) << "AudioManagerOpenBSD";
   SetMaxOutputStreamsAllowed(kMaxOutputStreams);
-  StubPathMap paths;
-
-  // Check if the pulse library is avialbale.
-  paths[kModulePulse].push_back(kPulseLib);
-  if (!InitializeStubs(paths)) {
-    DLOG(WARNING) << "Failed on loading the Pulse library and symbols";
-    return;
-  }
-
-  pulse_library_is_initialized_ = true;
 }
 
 AudioManagerOpenBSD::~AudioManagerOpenBSD() {
@@ -90,7 +50,7 @@ AudioManagerOpenBSD::~AudioManagerOpenBSD() {
 
 AudioOutputStream* AudioManagerOpenBSD::MakeLinearOutputStream(
     const AudioParameters& params) {
-  DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format);
+  DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format());
   return MakeOutputStream(params);
 }
 
@@ -98,20 +58,20 @@ AudioOutputStream* AudioManagerOpenBSD::MakeLowLatency
     const AudioParameters& params,
     const std::string& device_id) {
   DLOG_IF(ERROR, !device_id.empty()) << "Not implemented!";
-  DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format);
+  DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format());
   return MakeOutputStream(params);
 }
 
 AudioInputStream* AudioManagerOpenBSD::MakeLinearInputStream(
     const AudioParameters& params, const std::string& device_id) {
-  DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format);
+  DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format());
   NOTIMPLEMENTED();
   return NULL;
 }
 
 AudioInputStream* AudioManagerOpenBSD::MakeLowLatencyInputStream(
     const AudioParameters& params, const std::string& device_id) {
-  DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format);
+  DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format());
   NOTIMPLEMENTED();
   return NULL;
 }
@@ -121,7 +81,7 @@ AudioParameters AudioManagerOpenBSD::GetPreferredOutpu
     const AudioParameters& input_params) {
   // TODO(tommi): Support |output_device_id|.
   DLOG_IF(ERROR, !output_device_id.empty()) << "Not implemented!";
-  static const int kDefaultOutputBufferSize = 512;
+  static const int kDefaultOutputBufferSize = 2048;
 
   ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO;
   int sample_rate = kDefaultSampleRate;
@@ -145,15 +105,14 @@ AudioParameters AudioManagerOpenBSD::GetPreferredOutpu
 
 AudioOutputStream* AudioManagerOpenBSD::MakeOutputStream(
     const AudioParameters& params) {
-  if (pulse_library_is_initialized_)
-    return new PulseAudioOutputStream(params, this);
-
-  return NULL;
+  DLOG(WARNING) << "MakeOutputStream";
+  return new SndioAudioOutputStream(params, this);
 }
 
 // TODO(xians): Merge AudioManagerOpenBSD with AudioManagerPulse;
 // static
 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) {
+  DLOG(WARNING) << "CreateAudioManager";
   return new AudioManagerOpenBSD(audio_log_factory);
 }
 
